﻿using System.Collections.Generic;
using InseSoft.Models;
using InseSoft.Models.DbSetExtensions;
using InseSoft.Models.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace InseSoft.Tests.Unit.Models.DbSetExtensions
{
    [TestClass]
    public class EntidadCatalogoDbSetExtensionsTest
    {
        [TestMethod]
        public void GetActive_MatchesFound_RecordsFiltered()
        {
            var context = new Mock<IInseContext>();
            var fakeDbSet = new FakeDbSet<Linea>(CreateTestLineas());
            context.Setup(p => p.Lineas).Returns(fakeDbSet);
            var result = context.Object.Lineas.GetActive();

            foreach(var item in result)
                Assert.IsTrue(item.Activo);
        }
        
        #region Helpers

        private static IEnumerable<Linea> CreateTestLineas()
        {
            return new List<Linea>
                {
                    new Linea{Id=1, Nombre = "Linea #1", Activo = true},
                    new Linea{Id=1, Nombre = "Linea #2", Activo = false},
                    new Linea{Id=1, Nombre = "Linea #3", Activo = false},
                    new Linea{Id=1, Nombre = "Linea #4", Activo = true},
                };
        }

        #endregion
    }
}
